package com.mms.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateFormat {

    public static String dateTimeFormat(String dateString){
        SimpleDateFormat dateFormat12 = new SimpleDateFormat("MM-dd-yyyy KK:mm a");
        SimpleDateFormat dateFormat24 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String startTimeString= dateString;
        if (startTimeString.indexOf("AM")>-1) {
            startTimeString= startTimeString.replaceFirst("AM", "上午");
        }
        else startTimeString=startTimeString.replaceAll("PM", "下午");
        startTimeString = startTimeString.replaceAll("/", "-");
        try {
          Date date = null;
          date = dateFormat12.parse(startTimeString);
          startTimeString= dateFormat24.format(date);
          System.out.println(startTimeString);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return startTimeString;
    }
}
